from socket import *
from subprocess import Popen, PIPE


def get_ip_address():
    p = Popen("ifconfig eth0 | grep 'inet' | awk '{print $2}'", shell=True, stdout=PIPE)
    data = p.stdout.read()
    ip = str(data[:-1], encoding='UTF-8')
    if ":" in ip:
        ip = ip.split(":")[-1]
    return ip

if __name__ == '__main__':
    print(get_ip_address())